<?php
/**
 * ccNewsletter
 * @author Chill Creations <info@chillcreations.com>
 * @link http://www.chillcreations.com
 * @license GNU/GPL
**/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');

// get the controller name. If there is no controller name specified in the URL set to  the default, sendNewsletter
$controllerName = JRequest::getCmd( 'controller', 'sendNewsletter' );
switch($controllerName)
{
	case 'subscriber':
		JSubMenuHelper::addEntry(JText::_('CC_SEND_NEWSLETTER'), 'index.php?option=com_ccNewsletter');
		JSubMenuHelper::addEntry(JText::_('CC_SUBSCRIBER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=subscriber', true);
		JSubMenuHelper::addEntry(JText::_('CC_NEWSLETTER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=newsletter');
		JSubMenuHelper::addEntry(JText::_('CC_ACKNOWLEDGEMENT'), 'index.php?option=com_ccNewsletter&controller=acknowledgement');
		JSubMenuHelper::addEntry(JText::_('CC_IMPORT'), 'index.php?option=com_ccNewsletter&controller=import');
		JSubMenuHelper::addEntry(JText::_('CC_ABOUT_CCNEWSLETTER'), 'index.php?option=com_ccNewsletter&controller=about');
	break;

	case 'newsletter':
		JSubMenuHelper::addEntry(JText::_('CC_SEND_NEWSLETTER'), 'index.php?option=com_ccNewsletter');
		JSubMenuHelper::addEntry(JText::_('CC_SUBSCRIBER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=subscriber' );
		JSubMenuHelper::addEntry(JText::_('CC_NEWSLETTER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=newsletter',true);
		JSubMenuHelper::addEntry(JText::_('CC_ACKNOWLEDGEMENT'), 'index.php?option=com_ccNewsletter&controller=acknowledgement');
		JSubMenuHelper::addEntry(JText::_('CC_IMPORT'), 'index.php?option=com_ccNewsletter&controller=import');
		JSubMenuHelper::addEntry(JText::_('CC_ABOUT_CCNEWSLETTER'), 'index.php?option=com_ccNewsletter&controller=about');
	break;

	case 'ccNewsletterConfig':
		JSubMenuHelper::addEntry(JText::_('CC_SEND_NEWSLETTER'), 'index.php?option=com_ccNewsletter');
		JSubMenuHelper::addEntry(JText::_('CC_SUBSCRIBER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=subscriber' );
		JSubMenuHelper::addEntry(JText::_('CC_NEWSLETTER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=newsletter');
		JSubMenuHelper::addEntry(JText::_('CC_ACKNOWLEDGEMENT'), 'index.php?option=com_ccNewsletter&controller=acknowledgement');
		JSubMenuHelper::addEntry(JText::_('CC_IMPORT'), 'index.php?option=com_ccNewsletter&controller=import');
		JSubMenuHelper::addEntry(JText::_('CC_ABOUT_CCNEWSLETTER'), 'index.php?option=com_ccNewsletter&controller=about');
	break;

	case 'acknowledgement':
		JSubMenuHelper::addEntry(JText::_('CC_SEND_NEWSLETTER'), 'index.php?option=com_ccNewsletter');
		JSubMenuHelper::addEntry(JText::_('CC_SUBSCRIBER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=subscriber' );
		JSubMenuHelper::addEntry(JText::_('CC_NEWSLETTER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=newsletter');
		JSubMenuHelper::addEntry(JText::_('CC_ACKNOWLEDGEMENT'), 'index.php?option=com_ccNewsletter&controller=acknowledgement',true);
		JSubMenuHelper::addEntry(JText::_('CC_IMPORT'), 'index.php?option=com_ccNewsletter&controller=import');
		JSubMenuHelper::addEntry(JText::_('CC_ABOUT_CCNEWSLETTER'), 'index.php?option=com_ccNewsletter&controller=about');
	break;

	case 'about':
		JSubMenuHelper::addEntry(JText::_('CC_SEND_NEWSLETTER'), 'index.php?option=com_ccNewsletter');
		JSubMenuHelper::addEntry(JText::_('CC_SUBSCRIBER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=subscriber' );
		JSubMenuHelper::addEntry(JText::_('CC_NEWSLETTER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=newsletter');
		JSubMenuHelper::addEntry(JText::_('CC_ACKNOWLEDGEMENT'), 'index.php?option=com_ccNewsletter&controller=acknowledgement');
		JSubMenuHelper::addEntry(JText::_('CC_IMPORT'), 'index.php?option=com_ccNewsletter&controller=import');
		JSubMenuHelper::addEntry(JText::_('CC_ABOUT_CCNEWSLETTER'), 'index.php?option=com_ccNewsletter&controller=about', true);
	break;

	case 'import':
		JSubMenuHelper::addEntry(JText::_('CC_SEND_NEWSLETTER'), 'index.php?option=com_ccNewsletter');
		JSubMenuHelper::addEntry(JText::_('CC_SUBSCRIBER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=subscriber' );
		JSubMenuHelper::addEntry(JText::_('CC_NEWSLETTER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=newsletter');
		JSubMenuHelper::addEntry(JText::_('CC_ACKNOWLEDGEMENT'), 'index.php?option=com_ccNewsletter&controller=acknowledgement');
		JSubMenuHelper::addEntry(JText::_('CC_IMPORT'), 'index.php?option=com_ccNewsletter&controller=import', true);
		JSubMenuHelper::addEntry(JText::_('CC_ABOUT_CCNEWSLETTER'), 'index.php?option=com_ccNewsletter&controller=about');
	break;

	case 'sendNewsletter';
	default:
		JSubMenuHelper::addEntry(JText::_('CC_SEND_NEWSLETTER'), 'index.php?option=com_ccNewsletter&controller=sendNewsletter',true);
		JSubMenuHelper::addEntry(JText::_('CC_SUBSCRIBER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=subscriber' );
		JSubMenuHelper::addEntry(JText::_('CC_NEWSLETTER_MANAGEMENT'), 'index.php?option=com_ccNewsletter&controller=newsletter');
		JSubMenuHelper::addEntry(JText::_('CC_ACKNOWLEDGEMENT'), 'index.php?option=com_ccNewsletter&controller=acknowledgement');
		JSubMenuHelper::addEntry(JText::_('CC_IMPORT'), 'index.php?option=com_ccNewsletter&controller=import');
		JSubMenuHelper::addEntry(JText::_('CC_ABOUT_CCNEWSLETTER'), 'index.php?option=com_ccNewsletter&controller=about');
	break;
}
require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' );
$controllerName = 'ccNewsletterController'.$controllerName;
// Create the controller
$controller = new $controllerName();
// Perform the Request task
$controller->execute( JRequest::getCmd('task') );
// Redirect if set by the controller
$controller->redirect();
?>